﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace Wicresoft.UnifyShow2.Portal.Service
{
    public static class SysLog
    {
        public static void WriteSysLog(string sm)
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"SysLog\log.txt"))
            {
                StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"SysLog\log.txt", true);
                sw.WriteLine("=======================================================================================");
                sw.WriteLine("Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": Message:" + sm);
                sw.WriteLine("=======================================================================================");
                sw.WriteLine("\r");
                sw.Close();
                return;
            }
            else
            {
                File.Create(AppDomain.CurrentDomain.BaseDirectory + @"SysLog\log.txt");
                StreamWriter sw2 = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"SysLog\log.txt", true);
                sw2.WriteLine("=======================================================================================");
                sw2.WriteLine("Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": Message:" + sm);
                sw2.WriteLine("=======================================================================================");
                sw2.WriteLine("\r\n");
                sw2.Close();
                return;
            }
        }
    }
}